﻿@using SelfMadeMillionaire.Web.Infrastructure.ViewModels.Admin
@using SelfMadeMillionaire.Web.Infrastructure
@model NewUserReportViewModel
@{
	ViewBag.Title = "New User Report";
	Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

@using (Html.BeginForm("Index", "News", FormMethod.Get, new { @class = "form-horizontal" }))
{
	
	<fieldset class="border1">
		<legend class="border1">Report Options</legend>
		<div class="row">
			<div class="col-sm-8">
				<div class="form-group">
                    <div class="col-sm-12">
                        @Html.RadioButtonFor(m => m.ReportType, "today", new { name = "ReportType", id="rbToday" }) <label for="rbToday" style="margin-right:15px;">Today</label>
                        @Html.RadioButtonFor(m => m.ReportType, "week", new { name = "ReportType", id="rbWeek" }) <label for="rbWeek" style="margin-right:15px;">Week-To-Day</label>
                        @Html.RadioButtonFor(m => m.ReportType, "month", new { name = "ReportType", id="rbMonth" }) <label for="rbMonth" style="margin-right:15px;">Month-To-Day</label>
                        @Html.RadioButtonFor(m => m.ReportType, "year", new { name = "ReportType", id="rbYear" }) <label for="rbYear" style="margin-right:15px;">Year-To-Day</label>
                        @Html.RadioButtonFor(m => m.ReportType, "quarter", new { name = "ReportType", id="rbQuarter" }) <label for="rbQuarter" style="margin-right:15px;">Quarter-To-Day</label>
                        <button type="submit" id="view-report" class="btn btn-default">View Report</button>
                    </div>
				</div>
			</div>
		</div>
	</fieldset>
}

<div class="table_container">
	<div id="report-list">
		@Html.Partial("NewUserList")
	</div>
</div>

<script type="text/javascript">
	$(function () {

		$("#view-report").click(function (e) {
			e.preventDefault();
            GetList();
		});
	});

	function GetList() {
	    var reportType = "today";
	    var rbs = $("input[type='radio'][name='ReportType']:checked");
	    if (rbs.length > 0) {
	        reportType = rbs.val();
	    }

        $.get("@Url.Action("NewUser")",
				{
				    reportType: reportType
				},
					function (result) {
					    $("#report-list").html(result);
					});
    }
</script>

